﻿using System.Drawing;

namespace Microsoft.Office.PowerPoint.STAMP.Controls
{
    /// <summary>
    /// The type of Color indicator drawers
    /// </summary>
    public enum ColorIndicatorDrawer
    {
#pragma warning disable 1591
        FontIndicator = 0,
        RectangleIndicator = 1,
        Custom
#pragma warning restore 1591
    }

    /// <summary>
    /// Draws a color indicator graphic.
    /// </summary>
    public interface IColorIndicatorDrawer
    {
        /// <summary>
        /// Draws the color indicator.
        /// </summary>
        void DrawColorIndicator(int offset, Rectangle clippingRectangle, Graphics graphics, bool isButtonEnabled, Color selectedColor);
    }

    /// <summary>
    /// Draws a color indicator graphic for a font color selector.
    /// </summary>
    public class FontColorIndicatorDrawer : IColorIndicatorDrawer
    {
        /// <summary>
        /// Draws the color indicator.
        /// </summary>
        public void DrawColorIndicator(int offset, Rectangle clippingRectangle, Graphics graphics, bool isButtonEnabled, Color selectedColor)
        {
            Rectangle colorIndicatorRectangle = new Rectangle(clippingRectangle.Left + 3 + offset,
                                                              clippingRectangle.Top + 14 + offset,
                                                              clippingRectangle.Width - 18,
                                                              clippingRectangle.Height - 16);

            PointF textLocation = new PointF(((colorIndicatorRectangle.Right - colorIndicatorRectangle.Left) / 2) + colorIndicatorRectangle.Left - 6, clippingRectangle.Top + 1 + offset);
            Color textColor = ColorTranslator.FromHtml("#305090");
            graphics.DrawString("A", new Font("Georgia", 9, FontStyle.Bold), new SolidBrush(textColor), textLocation);

            if (isButtonEnabled)
            {
                graphics.FillRectangle(new SolidBrush(selectedColor), colorIndicatorRectangle);
            }
        }
    }

    /// <summary>
    /// Draws a rectangluar block filled with the chosen color.
    /// </summary>
    public class RectangleColorIndicatorDrawer : IColorIndicatorDrawer
    {
        /// <summary>
        /// Draws the color indicator.
        /// </summary>
        public void DrawColorIndicator(int offset, Rectangle clippingRectangle, Graphics graphics, bool isButtonEnabled, Color selectedColor)
        {
            Rectangle colorIndicatorRectangle = new Rectangle(clippingRectangle.Left + 3 + offset,
                                                              clippingRectangle.Top + 3 + offset,
                                                              clippingRectangle.Width - 17,
                                                              clippingRectangle.Height - 6);
            if (isButtonEnabled)
            {
                graphics.FillRectangle(new SolidBrush(selectedColor), colorIndicatorRectangle);
            }
        }
    }
}